package com.situ.mall.common.mapper;

import com.situ.mall.common.entity.Order;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.situ.mall.common.vo.OrderVO;
import com.situ.mall.common.vo.ResultVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.jdbc.Null;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author author
 * @since 2024-01-29
 */
public interface OrdersMapper extends BaseMapper<Order> {

    /* 后端请求 */
    //查询订单列表
    List<OrderVO> backList(String memberName, String workerName);

    //更新订单状态
    @Update("update orders set status = #{status} where id = #{id}")
    void update(Order order);


    /* 前端请求 */
    //查询订单列表
    List<OrderVO> list(String memberName, String workerName, Integer orderId, Integer memberId, String status);

    //生成订单
    @Insert("insert into orders (order_number, order_type_id, status, create_time, member_id, member_tel, member_name, member_detail, clinic_time, hospital, worker_id, money) VALUES (#{orderNumber}, #{orderTypeId}, #{status}, #{createTime}, #{memberId}, #{memberTel}, #{memberName}, #{memberDetail}, #{clinicTime}, #{hospital}, #{workerId}, #{money})")
    void order(Order order);

    //根据订单号查订单
    @Select("select * from orders where order_number = #{orderNumber}")
    Order selectByCode(String orderNumber);

    //接单
    @Update("update orders set worker_id = #{workerId}, status = '1', is_accept = 'true' where id = #{orderId}")
    void receiveOrder(Integer orderId, Integer workerId);

    //陪诊员订单列表
    List<OrderVO> workerOrderList(Integer workerId, String status);
}
